package com.project.service.Impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.CutPagBean;
import com.project.bean.StudentBean;
import com.project.dao.IStudentDao;
import com.project.mapper.IStudentMapper;
import com.project.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class StudentServiceImpl implements IStudentService {

    @Autowired
    private IStudentMapper studentMapper;


    @Override
    public IPage<StudentBean> findItem(int pageNO, String name, String className, String roomName) {
        return studentMapper.findByItem(new Page(pageNO,3),name,className,roomName);
    }

    @Override
    public void addStudent(StudentBean studentBean) {
      studentMapper.insert(studentBean);
    }

    @Override
    public void update(Integer id, Integer roomId) {
        StudentBean student = studentMapper.selectById(id);
        student.setRoomId(roomId);
        studentMapper.updateById(student);
    }

    @Override
    public StudentBean findById(int id) {
        return studentMapper.findById(id);
    }

    @Override
    public void del(Integer id) {
        studentMapper.deleteById(id);
    }
}
